package com.tmanager.persistence.dao;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Query;

import com.tmanager.persistence.entity.Activity;

class ActivityDAOImpl extends BaseDAO<Activity> implements ActivityDAO {

	public ActivityDAOImpl() {
		super(Activity.class);
	}

	@Override
	public List<Activity> getAllByDates(long userId, long timeStart, long timeEnd) {
		List<Activity> activities = new ArrayList<Activity>();

		Query query = getEntManager().createNamedQuery(Activity.GET_BY_USER_AND_DATES);
		query.setParameter("userId", userId);
		
		List results = query.getResultList();
        if (results != null) {
            for (Object obj : results) {
            	activities.add((Activity) obj);
            }
        }
		return activities;
	}
}
